package doct.mobi.album.myrxjava.base;

import android.content.Intent;

import doct.mobi.album.myrxjava.FlowAbleDropActivity;
import doct.mobi.album.myrxjava.FlowAbleLatestActivity;
import doct.mobi.album.myrxjava.FlowAbleResponsiveActivity;
import doct.mobi.album.myrxjava.RxManager;

/**
 * Created by huangli on 17/12/24.
 * link : https://www.jianshu.com/u/c50b715ccaeb
 */

public class MainActivity extends BaseListActivity{
    @Override
    public void initItems() {
        addListviewItem("基本使用", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxJavaBase();
            }
        });
        addListviewItem("线程切换1(单次切换)", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxJavaThread_Demo1();
            }
        });
        addListviewItem("线程切换2(多次切换)", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxJavaThread_Demo2();
            }
        });
        addListviewItem("Map转换", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxJavaMap();
            }
        });
        addListviewItem("flatMap转换", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxFlatMap();
            }
        });
        addListviewItem("ConcatMap转换", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxConcatMap();
            }
        });
        addListviewItem("Zip转换", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.rxZip();
            }
        });
        addListviewItem("Back pressure 1", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.backPressureDemo1();
            }
        });
        addListviewItem("Back pressure 2", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.backPressureDemo2();
            }
        });
        addListviewItem("Relieve Back pressure 通过 Filter", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.relieveBackPressureFilter();
            }
        });
        addListviewItem("Relieve Back pressure 通过 Simple", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.relieveBackPressureSample();
            }
        });
        addListviewItem("Relieve Back pressure 通过 Sleep", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.relieveBackPressureDelay();
            }
        });
        addListviewItem("Flowable 基本使用", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableBase();
            }
        });
        addListviewItem("Flowable在不同线程里面，演示水缸效果", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableThread();
            }
        });
        addListviewItem("Flowable水缸缓存大小", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowable128();
            }
        });
        addListviewItem("Flowable的大水缸同样也会有性能问题", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableBuffer();
            }
        });
        addListviewItem("Flowable的Backpressure策略 之 DROP", new ItemClickListener() {
            @Override
            public void itemClicked() {
                Intent intent = new Intent(MainActivity.this, FlowAbleDropActivity.class);
                startActivity(intent);
            }
        });
        addListviewItem("Flowable的Backpressure策略 之 Latest", new ItemClickListener() {
            @Override
            public void itemClicked() {
                Intent intent = new Intent(MainActivity.this, FlowAbleLatestActivity.class);
                startActivity(intent);
            }
        });
        addListviewItem("FlowableEmitter中requested接口作用 同步的情况", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableEmitterReqSync();
            }
        });
        addListviewItem("FlowableEmitter中requested接口作用 异步的情况", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableEmitterReqAsync();
            }
        });
        addListviewItem("FlowableEmitter中requested接口完成响应式拉取", new ItemClickListener() {
            @Override
            public void itemClicked() {
                Intent intent = new Intent(MainActivity.this, FlowAbleResponsiveActivity.class);
                startActivity(intent);
            }
        });
        addListviewItem("一个响应式拉去示例", new ItemClickListener() {
            @Override
            public void itemClicked() {
                RxManager.flowableResponsiveDemo(MainActivity.this);
            }
        });
    }
}
